<?php
require 'execute/auth.php';
require 'config/config.php';

mydb_connect();
?>
<!DOCTYPE html>
<!--[if lt IE 7 ]><html lang="en" class="ie6 ielt7 ielt8 ielt9"><![endif]--><!--[if IE 7 ]><html lang="en" class="ie7 ielt8 ielt9"><![endif]--><!--[if IE 8 ]><html lang="en" class="ie8 ielt9"><![endif]--><!--[if IE 9 ]><html lang="en" class="ie9"> <![endif]--><!--[if (gt IE 9)|!(IE)]><!--> 
<html lang="en"><!--<![endif]--> 
	
<!-- Mirrored from wbpreview.com/previews/WB0070A9H/index.htm by HTTrack Website Copier/3.x [XR&CO'2013], Wed, 22 Jan 2014 10:30:52 GMT -->
<head>
		<meta charset="utf-8">
		<title>Dashboard - TechAfghanistan</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="keywords" content="opensource rich wysiwyg text editor jquery bootstrap execCommand html5" />
    <meta name="description" content="This tiny jQuery Bootstrap WYSIWYG plugin turns any DIV into a HTML5 rich text editor" />
    <link rel="apple-touch-icon" href="http://mindmup.s3.amazonaws.com/lib/img/apple-touch-icon.png" />
    <link rel="shortcut icon" href="http://mindmup.s3.amazonaws.com/lib/img/favicon.ico" >
    <link href="js/external/google-code-prettify/prettify.css" rel="stylesheet">
    <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
    <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" rel="stylesheet">
		<link href="http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script src="http://malsup.github.io/jquery.form.js"></script>
		<script src="js/external/jquery.hotkeys.js"></script>
    <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
    <script src="js/external/google-code-prettify/prettify.js"></script>
		<link href="css/index.css" rel="stylesheet">
    <script src="js/bootstrap-wysiwyg.js"></script>


<script type="text/javascript">
$(function(){
	$(".editPost").on("click",function(){
jQuery.param.querystring(window.location.href, 'valueA=321&valueB=123');
	});
});
</script>
		<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
	<style type="text/css">
 		#editor {
 			overflow:scroll; 
 			max-height:250px;
 			width: 650px;
 		}
	</style>	
	<script type="text/javascript">	
		$(function(){
			$('#show_link').click(function(event) {
  $('html').one('click',function() {
				$("#link").hide();
  });

  event.stopPropagation();
});
		});
		</script>	
	<link href="css/site.css" rel="stylesheet">
	<script type="text/javascript">
		$(function(){
			$("#show_link").on("click",function(){
				$("#link").show();
			});

			$("#editor").on("keyup",function(){
				$(".content").html($(this).html());
			});
		});
	</script>
	

		<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
	</head>
	<body>
		<div class="container">
			<div class="navbar">
				<div class="navbar-inner">
				<div class="container">
						<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand" href="#">TechAfghanistan</a>
						<div class="nav-collapse">
							<ul class="nav">
									<li class="dropdown">
									<a href="help.html" class="dropdown-toggle" data-toggle="dropdown">Tours <b class="caret"></b></a>
									<ul class="dropdown-menu">
										<li>
											<a class="addLink" href="help.html">Introduction Tour</a>
										</li>
										<li>
											<a href="help.html">Project Organisation</a>
										</li>
										<li>
											<a href="help.html">Task Assignment</a>
										</li>
										<li>
											<a href="help.html">Access Permissions</a>
										</li>
										<li class="divider">
										</li>
										<li class="nav-header">
											Files
										</li>
										<li>
											<a href="help.html">How to upload multiple files</a>
										</li>
										<li>
											<a href="help.html">Using file version</a>
										</li>
									</ul>
								</li>
							</ul>
							<form class="navbar-search pull-right" action="#">
								<input type="text" class="search-query span2" placeholder="Search" />
							</form>
							<ul class="nav pull-right">
								<li>
									<a href="profile.html"><i class="fa fa-user"> username</i></a>
								</li>
								
							</ul>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="span3">
					<div class="well" style="padding: 8px 0;">
						<ul class="nav nav-list">
							<li class="nav-header">
								TechAfghanistan
							</li>
							<li>
								<a href="news_lang_editor.php"><i class="icon-home"></i> Posts</a>
							</li>
						</ul>
					</div>
				</div>
			<div class="span9">
				<?php if(isset($_GET['delete']) && $_GET['delete']=="success"){
					?>
					<div class="alert alert-warning">Post deleted successfully</div>
					<?php
				} 

				?>
				<?php if(isset($_GET['update']) && $_GET['update']=="success"){
					?>
					<div class="alert alert-success">Post updated successfully</div>
					<?php
				} 

				?>
					<h2>
						Posts
					</h2>
					
					<table class="table table-bordered">
						<thead>
							<tr>
								<th>
									#
								</th>
								<th style="width:30%">
									Title
								</th>
								<th style="width:50%">
									Description
								</th>
								<th>
									Publish Date
								</th>
								<th>
									Physical Author
								</th>
								<th style="width: 20%;">
									Actions
								</th>
								
								
								</tr>
							
						</thead>
						<tbody>
							<?php
								$authorSelectQry = $conn->query("SELECT * FROM `news` WHERE `ispub`='2' OR `ispub`='yes' ORDER BY pub_date DESC");
								$count = 1;
								while($authorSelectRow=$authorSelectQry->fetch()){
									$select_author = $conn->query("SELECT * FROM `users` WHERE id = '".$authorSelectRow['physical_author_id']."'");
									$author = $select_author->fetch();
									$name = $author['firstname'] . " " . $author['lastname'];
								?>
								<tr class="<?php if($authorSelectRow['ispub']=='yes') { echo 'success'; } else { echo "warnin"; } ?>""><td><?php echo $count; ?></td><td><?php echo $authorSelectRow['title']; ?></td><td><?php echo $authorSelectRow['description']; ?></td><td><?php echo $authorSelectRow['pub_date']; ?></td><td><?php echo $name; ?></td><td><a href="http://tech.af/author/news_edit.php?id=<?php echo $authorSelectRow['id']; ?>">Edit</a> | <a href="http://tech.af/author/execute/confirm.php?id=<?php echo $authorSelectRow['id']; ?><?php if($authorSelectRow['ispub']=='yes') echo '&unpublish=yes'; ?>"><?php if($authorSelectRow['ispub']=='yes'){ echo 'Un-Publish'; } else { echo "Publish"; }  ?></a> | <a href="http://tech.af/author/execute/remove_post.php?id=<?php echo $authorSelectRow['id']; ?>">Delete</a></td></tr>
									<?php $count++;
								}
							?>
						</tbody>
						
					</table>
					
					
				</div>
			</div>
		</div>

    <script>
  $(function(){
    function initToolbarBootstrapBindings() {
      var fonts = ['Serif', 'Sans', 'Arial', 'Arial Black', 'Courier', 
            'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande', 'Lucida Sans', 'Tahoma', 'Times',
            'Times New Roman', 'Verdana'],
            fontTarget = $('[title=Font]').siblings('.dropdown-menu');
      $.each(fonts, function (idx, fontName) {
          fontTarget.append($('<li><a data-edit="fontName ' + fontName +'" style="font-family:\''+ fontName +'\'">'+fontName + '</a></li>'));
      });
      $('a[title]').tooltip({container:'body'});
    	$('.dropdown-menu input').click(function() {return false;})
		    .change(function () {$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');})
        .keydown('esc', function () {this.value='';$(this).change();});

      $('[data-role=magic-overlay]').each(function () { 
        var overlay = $(this), target = $(overlay.data('target')); 
        overlay.css('opacity', 0).css('position', 'absolute').offset(target.offset()).width(target.outerWidth()).height(target.outerHeight());
      });
      if ("onwebkitspeechchange"  in document.createElement("input")) {
        var editorOffset = $('#editor').offset();
        $('#voiceBtn').css('position','absolute').offset({top: editorOffset.top, left: editorOffset.left+$('#editor').innerWidth()-35});
      } else {
        $('#voiceBtn').hide();
      }
	};
	function showErrorAlert (reason, detail) {
		var msg='';
		if (reason==='unsupported-file-type') { msg = "Unsupported format " +detail; }
		else {
			console.log("error uploading file", reason, detail);
		}
		$('<div class="alert"> <button type="button" class="close" data-dismiss="alert">&times;</button>'+ 
		 '<strong>File upload error</strong> '+msg+' </div>').prependTo('#alerts');
	};
    initToolbarBootstrapBindings();  
	$('#editor').wysiwyg({ fileUploadError: showErrorAlert} );
    window.prettyPrint && prettyPrint();
  });
</script>
    <script src="js/site.js"></script>
    <script type="text/javascript">
    $(function(){
    	$("#r-self, #r-other").change(function () {
			var checked = $('input[name=author_who]:checked', '#new-file').val();
    		if(checked == "self"){
    			$(".other-div").hide();
    			$("#isSelf").val("yes");
    		}
    		else{
    			$(".other-div").show();
    			$("#isSelf").val("no");
    		}
    	});
    	//callback handler for form submit
		

			function onsuccess(response,status){
				var response = response.split("||");
				if(response[0] != "error"){
					$("#addNewAuthor").modal("hide");
	      	$("#success-author").show();
	      	$("#other-author-id").append(response);
	      	$('#addNewAuthorForm').trigger("reset");
	      }
	      else{
	      	alert("Error: " + response[1]);
	      }
			 }
			 $("#addNewAuthorForm").on('submit',function(){
			  var options={
			   url     : 'execute/add_author.php',
			   success : onsuccess
			  };
			  $(this).ajaxSubmit(options);
			 return false;
			 });
		});
    </script>

	</body>

<!-- Mirrored from wbpreview.com/previews/WB0070A9H/index.htm by HTTrack Website Copier/3.x [XR&CO'2013], Wed, 22 Jan 2014 10:31:21 GMT -->
</html>